package com.thalesgroup.graphFramework.sortMethods;

import java.util.ArrayList;

import com.thalesgroup.graphFramework.core.Graph;
import com.thalesgroup.graphFramework.core.GraphBuilder;
import com.thalesgroup.graphFramework.core.Vertex;
import com.thalesgroup.graphFramework.core.impl.GraphBuilderImpl;
import com.thalesgroup.graphFramework.searchMethods.DepthFirstSearch;

public class TopologicalSortTest {
	public static void main(String[] args) {
		Graph<String, Void> graph;

		/* Construction */
		GraphBuilder<String, Void> b=new GraphBuilderImpl<String, Void>();
		b.createNewGraph();
		
		Vertex<String, Void> calecon=b.createVertex("calecon");
		Vertex<String, Void> pantalon=b.createVertex("pantalon");
		Vertex<String, Void> ceinture=b.createVertex("ceinture");
		Vertex<String, Void> chemise=b.createVertex("chemise");
		Vertex<String, Void> cravate=b.createVertex("cravate");
		Vertex<String, Void> veste=b.createVertex("veste");
		Vertex<String, Void> chaussettes=b.createVertex("chaussettes");
		Vertex<String, Void> chaussures=b.createVertex("chaussures");
		Vertex<String, Void> montre=b.createVertex("montre");
		
		b.createEdge(calecon, pantalon);
		b.createEdge(calecon, chaussures);
		b.createEdge(pantalon, ceinture);
		b.createEdge(pantalon, chaussures);
		b.createEdge(ceinture, veste);
		b.createEdge(chemise, ceinture);
		b.createEdge(chemise, cravate);
		b.createEdge(cravate, veste);
		b.createEdge(chaussettes, chaussures);

		b.finalizeGraph();
		graph=b.getCurrentGraph();
		
		Vertex<String, Void>[] vertices = TopologicalSort.sort(graph);
		
		for (Vertex<String, Void> vertex : vertices) {
			System.out.println(vertex.getVertex() + "," + vertex.getUserFeature(DepthFirstSearch.processedDateKey));
		}
	}
}
